﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WPFDBBrowser.Framework
{
    public class SingletonFactory<TInterface, TRealization>
       where TRealization : TInterface, new()
    {
        static TInterface instance;
        static object instanceLock = new object();

        public static TInterface GetInstance()
        {
            lock (instanceLock)
            {
                if (instance == null) instance = new TRealization();
            }
            return instance;
        }
    }

    public class SingletonFactory<TRealization>
        where TRealization : new()
    {
        static TRealization instance;
        static object instanceLock = new object();

        public static TRealization GetInstance()
        {
            lock (instanceLock)
            {
                if (instance == null) instance = new TRealization();
            }
            return instance;
        }
    }
}
